#include "../include/mem_hash.h"
#include <malloc.h>

struct pointer_statist *PS = NULL;

int main()
{
	void *p1 = malloc(1);	
	void *p2 = malloc(1);	
	void *p3 = malloc(1);	
	void *p4 = malloc(1);	
	void *p5 = malloc(1);	
	void *p6 = malloc(1);	
	void *p7 = malloc(1);	
	void *p8 = malloc(1);	
	void *p9 = malloc(1);	

	hash_add_pointer_statist(&PS, p1, 1);
	hash_add_pointer_statist(&PS, p2, 2);
	hash_add_pointer_statist(&PS, p3, 3);
	hash_add_pointer_statist(&PS, p4, 4);
	hash_add_pointer_statist(&PS, p5, 5);
	hash_add_pointer_statist(&PS, p6, 6);
	hash_add_pointer_statist(&PS, p7, 7);
	hash_add_pointer_statist(&PS, p8, 8);

	struct pointer_statist *tmp = NULL;

	tmp = hash_find_pointer_statist(PS, p2);
	if (tmp != NULL) {
		printf("1 size %ld\n", tmp->size);
	} else {
		printf("not found.\n");
	}

	tmp = hash_find_pointer_statist(PS, p3);
	if (tmp != NULL) {
		printf("2 size %ld\n", tmp->size);
	} else {
		printf("not found.\n");
	}
	
	hash_delete_pointer_statist(&PS, tmp);
	tmp = NULL;

	tmp = hash_find_pointer_statist(PS, p2);
	if (tmp != NULL) {
		printf("3 size %ld\n", tmp->size);
	} else {
		printf("not found.\n");
	}

	tmp = hash_find_pointer_statist(PS, p3);
	if (tmp != NULL) {
		printf("4 size %ld\n", tmp->size);
	} else {
		printf("not found.\n");
	}
	
	return 0;
}
